<?php

class DB_URL_CITY extends ORM_Table {
    static protected $table_name = 'url_city';
    
    static public function getTableName($params = null) {
        //$table_name = self::$table_name.substr($params['article_type_id'], 0, 1);
        return self::$table_name;
    }

    /**
     * 添加记录
     * @param <String> $uhash
     */
    static function setUpdate($uhash) {
        $city   = empty($_SESSION['site']['city'])?'':$_SESSION['site']['city'];
        if(!empty($city)) {
            $has    = ORM_Finder::findOne(DB_URL_CITY,"name='$city' and uhash='$uhash'");
            if($has) {
                $has->setClick($has->getClick()+1);
                $has->save();
            }else{
                $has    = new DB_URL_IE();
                $has->setUhash($uhash);
                $has->setName($city);
                $has->save();
            }
        }
        return $has;
    }
}

